import xlrd
class ReadExcel():
    def read_excel(self):
        # 打开excel表
        book =xlrd.open_workbook("../data测试数据/data1.xlsx")
        #找到sheet页
        table = book.sheet_by_name("Sheet1")
        #获取总行数总列数
        row_Num =table.nrows
        col_Num = table.ncols
        s = []
        # 这是第一行数据，作为字典的key值
        key =table.row_values(0)
        if row_Num<=1:
            print("没有数据了")
        else:
            j = 1
            for i in range(row_Num-1):
                # print(i)
                d = {}
                values = table.row_values(j)
                for x in range(col_Num):
                    # print(values)
                    d[key[x]] =values[x]
                j+=1
                s.append(d)
            return s

if __name__ == '__main__':
    r =ReadExcel()
    s = r.read_excel()
    print(s)